package com.lucenly.spell.activity

import android.graphics.Color
import androidx.fragment.app.Fragment
import com.lucenly.spell.R
import com.lucenly.spell.base.BaseActivity
import com.lucenly.spell.databinding.ActivityMainBinding
import com.lucenly.spell.fragment.HomeFragment
import com.lucenly.spell.fragment.MyFragment
import com.lucenly.spell.fragment.SpellFragment
import com.lucenly.spell.fragment.TypeFragment
import com.next.easynavigation.adapter.ViewPagerAdapter
import kotlinx.android.synthetic.main.activity_base.*

class MainActivity : BaseActivity<ActivityMainBinding>() {
    private val fragments = arrayListOf<Fragment>()
    private val tabText =
        arrayOf("首页", "分类", "开团", "我的")

    //未选中icon
    private val normalIcon =
        intArrayOf(R.mipmap.home, R.mipmap.fenlei, R.mipmap.kt, R.mipmap.w)

    //选中时icon
    private val selectIcon =
        intArrayOf(R.mipmap.home_xz, R.mipmap.fenlei_xz, R.mipmap.kt_xz, R.mipmap.w_xz)
    override fun getViewBinding(): ActivityMainBinding {
        return ActivityMainBinding.inflate(layoutInflater,baseBinding.root,true)
    }

    override fun setTitle(): String {
       return "主页"
    }

    override fun initData() {
//        initNavication()
        initViewPager()
    }

    private fun initViewPager() {
        val homeFragment = HomeFragment()
        val typeFragment = TypeFragment()
        val spellFragment = SpellFragment()
        val myFragment = MyFragment()
        fragments.add(homeFragment)
        fragments.add(typeFragment)
        fragments.add(spellFragment)
        fragments.add(myFragment)
        binding.vpSetup.adapter = ViewPagerAdapter(supportFragmentManager,fragments)
        binding.navigationBar.titleItems(tabText)
            .normalIconItems(normalIcon)
            .selectIconItems(selectIcon)
            .setupWithViewPager(binding.vpSetup)
            .navigationBackground(Color.parseColor("#ffffff"))
            .build()
    }

    override fun initEvent() {
    }

    override fun startObserve() {
    }

    override fun getStatusType(): Int {
        return 0
    }
}